/**
 * 上市公司高管减持爬虫
 *  
 */
import {Base,Item} from '../base';
class tyzfcg extends Base{
    deji:number=1;
  constructor(){
      super();
      this.name='上市公司高管减持';
      this.enabled = true;
      this.encode = "utf-8";
      this.debug = false;
      this.timeout = 1000000;
      this.collection = "lnxm";
      this.collectionShowName="辽宁项目爬虫";
      this.keyField = "title";
      
  }
  getItems(pageIndex:number) {
    let num = pageIndex + 1;
    let url = `http://datainterface.eastmoney.com/EM_DataCenter/JS.aspx?type=GG&sty=ZCPHB&p=${num}&ps=30&js=var%20HONftSZv={pages:(pc),data:[(x)]}&sr=false&stat=1&st=1&rt=50542831`;
    let content = this.spider.getSync(url);
    let result:Item[] = [];
    let long=content.length;
    let newString=content.substring(30,long-3);
    let stringArray=newString.split('","');
    let that =this;
    stringArray.forEach(function(ele,index){
        let item =that.buildItem();
        let newStringArray= ele.split(',');
        item.source = that.name;
        item.title=newStringArray[1];
        (<any>item)['pm']=that.deji;
        (<any>item)['dm']=newStringArray[0];
        (<any>item)['gfje']=newStringArray[2];
        (<any>item)['gfse']=newStringArray[3];
        (<any>item)['zjcjj']=newStringArray[4];
        (<any>item)['zxj']=newStringArray[5];
        (<any>item)['zdf']=newStringArray[6];
        (<any>item)['mc']=newStringArray[1];
        that.deji++;
        result.push(item);
    });
    return result;
}
  getPageCount ():number{
      return 14;
  }
}
module.exports=new tyzfcg();